#!/bin/bash
DEPLOY_DIR=`pwd`
LOGS_DIR=$DEPLOY_DIR/logs
if [ ! -d $LOGS_DIR ]; then
    mkdir $LOGS_DIR
fi

SERVER_NAME=`hostname`

PIDS=`ps -ef | grep java | grep "$DEPLOY_DIR" |awk '{print $2}'`

if [ -z "$PIDS" ]; then
    echo "ERROR: The $SERVER_NAME does not started!"
    exit 0
fi

for PID in $PIDS ; do
    kill $PID > /dev/null 2>&1
done

echo "OK!"
echo "PID: $PIDS"